package org.hdl.anima.handler;

import org.hdl.anima.Application;
import org.hdl.anima.message.IRequest;
import org.hdl.anima.message.ResponseCallback;
import org.hdl.anima.session.ISession;

/**
 * 
 * @author qiuhd
 * @since  2014-2-18
 * @version V1.0.0
 */
public abstract class AbstractServiceHandler<T> implements Handler {
	
	protected Application app;
	
	public void setApplication(Application app) {
		this.app = app;
	}

	@SuppressWarnings("unchecked")
	@Override
	public void handle(IRequest request, ISession session,
			ResponseCallback callBack) throws Exception {
		T t = null;
		try {
			t = (T) request ;
		}catch(Exception e) {
			throw new IllegalStateException("");
		}
		doHanldle(t,session,callBack);
	}
	
	public abstract void doHanldle(T req,ISession session, ResponseCallback cb)throws Exception ;
}

